package com.league.zjxn.jetpack.repository

import com.league.zjxn.app.SPSConstance
import com.league.zjxn.base.BaseManager
import com.league.zjxn.entity.HomeDataResponse
import com.league.zjxn.entity.HomeSearchResponse
import com.league.zjxn.entity.TrendData1Response
import rxhttp.RxHttp
import rxhttp.await

open class HomeRepository : BaseManager() {

    suspend fun homeIndexApp(): HomeDataResponse =
        RxHttp.get("/api/index/indexApp")
            .addHeader("token", SPSConstance.token ?: "")
            .await()

    suspend fun homeTrendData(type: String, page: String, limit: String): TrendData1Response =
        RxHttp.get("/api/news/getNewsList")
            .addHeader("token", SPSConstance.token ?: "")
            .add("type", type)
            .add("page", page)
            .add("limit", limit)
            .await()


    suspend fun homeSearch(key: String, page: String, limit: String): HomeSearchResponse =
        RxHttp.get("/api/index/search")
            .addHeader("token", SPSConstance.token ?: "")
            .add("key", key)
            .add("page", page)
            .add("limit", limit)
            .await()
}